package com.walkline.app;

import net.rim.blackberry.api.homescreen.HomeScreen;
import net.rim.device.api.i18n.Locale;
import net.rim.device.api.ui.UiApplication;

import com.walkline.screen.RedFlowerScreen;
import com.walkline.util.Enumerations.ShortcutKey;

public class RedFlowerApp extends UiApplication
{
	private RedFlowerAppConfig _appConfig;

	public static void main(String[] args)
    {
    	if (args != null && args.length > 0 && args[0].equals("startup"))
    	{
    		RedFlowerAppConfig config = new RedFlowerAppConfig();
    		config.initialize();

    		int keyIndex = config.getShortcutKey();
    		String nickName = config.getNickname();
    		String newAppName = RedFlowerAppConfig.APP_NAME + nickName;

    		if (keyIndex > 0)
    		{
    			String shortcut_key = ShortcutKey.choicesShortcutKeys[keyIndex];

    			newAppName += "(" + shortcut_key + RedFlowerAppConfig.UNDERLINE + ")";
    		}

			HomeScreen.setName(newAppName, 0);
    	} else {
    		RedFlowerApp theApp = new RedFlowerApp();       
    	    theApp.enterEventDispatcher();
    	}
	}

    public RedFlowerApp()
    {
    	_appConfig = new RedFlowerAppConfig();
    	_appConfig.initialize();

    	if (_appConfig.isUseEnglish()) {Locale.setDefault(Locale.get(Locale.LOCALE_en));}

    	pushScreen(new RedFlowerScreen(_appConfig));
    }
}